﻿import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import "../../js/UI.js" as Style
Rectangle {
    id: rect
    color: "transparent"
    width: m_root_id.width
    height: m_lineValue*1.5
    property alias m_headSource: m_head.m_source
    property int m_jurgePage: 0
    property bool m_visible: true
    property string m_name: ""
    property bool is_shiled: true
    signal channelDetail(var chnnelid)
    signal enterchannelSignal(var chnnelid )

    HeadImage {
        id: m_head
        width:is_PCScreen ? 0.7*parent.height : parent.height*0.8
        height: width
        anchors.left: parent.left
        anchors.leftMargin: m_lineValue*0.3
        anchors.verticalCenter: parent.verticalCenter
        MouseArea{
            anchors.fill: parent
            onClicked: {
                channelDetail(1)
            }
        }
    }
    Item{
        anchors.left: m_head.right
        anchors.right: parent.right
        height: parent.height
        Column{
            anchors.left: parent.left
            anchors.leftMargin: 0.2*m_lineValue
            anchors.top: parent.top
            anchors.topMargin: 0.3*m_lineValue
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 0.3*m_lineValue
            anchors.right: parent.right
            //spacing: 0.05*m_lineValue
            Item{
                width: childrenRect.width
                height: parent.height*0.5
                Image{
                    anchors.left: parent.left
                    width: 0.4*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    height:is_PCScreen ? 0.35*m_lineValue : 0.4*m_lineValue
                    visible: m_visible
                    id:selfchannel
                    source: "qrc:/images/channel_self.svg"
                }
                AText{
                    anchors.left:selfchannel.visible==true ?  selfchannel.right : parent.left
                    anchors.leftMargin:selfchannel.visible==true ? 0.1*m_lineValue : 0
                    anchors.verticalCenter: parent.verticalCenter
                    width:is_PCScreen ?  2*m_lineValue : 4*m_lineValue
                    elide:  Text.ElideRight
                    id:chnnelName
                    text:m_jurgePage==1 ? qsTr("%1").arg(m_name) :qsTr("%1").arg(m_name)
                    font.pointSize:is_PCScreen ? 13 : 18
                    color: "#323232"
                    font.family: Style.fontfamily
                }
            }
            Item{
                width: childrenRect.width
                height: parent.height*0.5
                Image{
                    id:img
                    anchors.left: parent.left
                    anchors.verticalCenter: parent.verticalCenter
                    sourceSize.width: is_PCScreen ? 0.3*m_lineValue : 0.4*m_lineValue
                    sourceSize.height: width
                    source: "qrc:/images/conference3.svg"
                }
                AText{
                    id:inline
                    anchors.left: img.right
                    anchors.leftMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("%1/%2").arg(model.connect_count).arg(model.member_count)
                    font.pointSize: is_PCScreen ? 13 : 18
                    color: "#cccccc"
                    font.family: Style.fontfamily
                }
                Image{
                    id:imgpingbi
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: inline.right
                    anchors.leftMargin: 0.2*m_lineValue
                    visible: is_shiled
                    sourceSize.width: is_PCScreen ? 0.2*m_lineValue : 0.4*m_lineValue
                    sourceSize.height: width
                    source: "qrc:/images/pingbi2.svg"
                }
                Image{
                    id:voiceimg
                    visible: false
                    anchors.left:imgpingbi.visible ? imgpingbi.right : inline.right
                    anchors.leftMargin: 0.05*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    sourceSize.width: is_PCScreen ? 0.2*m_lineValue : 0.4*m_lineValue
                    sourceSize.height: width
                    source: "qrc:/images/signal1.svg"
                    onVisibleChanged: {
                        if(visible)
                            speaketime.running = true
                        else
                            speaketime.running = false
                    }
                }
                Timer{
                    id:speaketime
                    interval:200
                    repeat: true
                    running: false
                    property int m_index: 1
                    onTriggered: {
                        voiceimg.source = "qrc:/images/signal"+m_index+".svg"
                        if(m_index==6){
                            m_index=1
                        }
                        m_index++
                    }
                }

            }
        }
        MouseArea {
            id: mouseArea
            anchors.fill: parent
            onClicked: {
                enterchannelSignal(1)
            }
        }
    }
    states: State {
        name: "pressed"; when: mouseArea.pressed
        PropertyChanges { target: rect ; color: Style.transparent_color;}
    }
}

